package com.CuiChangHe.studentmanager.controller;

import com.CuiChangHe.studentmanager.dao.StudentSimpleInfoDao;
import com.CuiChangHe.studentmanager.entity.studentsimpleinfo.StudentSimpleInfoReturnMsg;
import com.CuiChangHe.studentmanager.service.studentsimpleinfo.StudentSimpleInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Description :用户基本信息Controller
 * @Author :崔昌赫
 * @Date : 2021/11/16
 */
@RestController
public class StudentSimpleInfoController {

    private StudentSimpleInfoService service;

    @Autowired
    public void setService(StudentSimpleInfoService service) {
        this.service = service;
    }

    @GetMapping("/student/list")
    StudentSimpleInfoReturnMsg getStudentInfo(){
        return service.getStudentList();
    }

    @GetMapping("/student/get/{studentid}")
    StudentSimpleInfoReturnMsg getStudentInfoByStudentId(@PathVariable String studentid){
        return service.getStudentInfoByStudentId(studentid);
    }

    @PutMapping("/student/update/{studentid}")
    StudentSimpleInfoReturnMsg updateStudentSimpleInfoByStudentId(@PathVariable String studentid, @RequestBody StudentSimpleInfoDao data){
        return service.updateStudentInfoByStudentId(studentid,data);
    }

    @PostMapping("/student/add")
    StudentSimpleInfoReturnMsg addNewStudentSimpleInfo(@RequestBody StudentSimpleInfoDao data){
        return service.addNewStudentSimpleInfo(data);
    }

    @DeleteMapping("/student/delete/{studentid}")
    StudentSimpleInfoReturnMsg deleteStudentSimpleInfoByStudentId(@PathVariable String studentid){
        return service.deleteStudentSimpleInfo(studentid);
    }

}
